<template>
  <div class="cart-list">
    <scroll class="content" ref="scroll" :probe-type="3" :pull-up-load="true">
      <cart-list-item
        v-for="(item, index) in cartList"
        :key="index"
        :item-info="item"
        :item-index="index"
        @imgLoad="imgLoad"
        class="cart-list-item"
      ></cart-list-item>
    </scroll>
  </div>
</template>

<script>
import Scroll from "components/common/scroll/Scroll.vue";
import CartListItem from "./CartListItem.vue";

import { mapGetters } from "vuex";

export default {
  name: "CartList",
  components: {
    Scroll,
    CartListItem,
  },
  computed: {
    ...mapGetters(["cartList"]),
  },
  activated() {
    //   进入时做一次刷新
    this.$refs.scroll.refresh();
  },
  // 监听购物车图片加载
  methods: {
    imgLoad() {
      this.$refs.scroll.refresh();
    },
  },
};
</script>

<style scoped>
.cart-list {
  height: calc(100% - 44px - 49px - 40px);
}

.content {
  /* 计算符号要分开 */
  overflow: hidden;
  width: 100%;
  height: 100%;
  /* background-color: pink; */
}
.cart-list-item {
  background: url("../../../assets/img/regisetr/login2.jpg");
  background-size: cover;
}
</style>
